package com.test.spring2025_4_18.Config;

import com.test.spring2025_4_18.Model.Student;
import jakarta.annotation.PostConstruct;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Scope;
import org.springframework.web.context.annotation.ApplicationScope;
import org.springframework.web.context.annotation.RequestScope;
import org.springframework.web.context.annotation.SessionScope;

@Configuration
public class BeanConfig {

    @PostConstruct
    public void inti(){
        System.out.println("初始化完毕...");
    }

    @Bean
    public Student singleTon(){
        return new Student();
    }

    @Bean
    @Scope("prototype")
    public Student prototypeStu(){
        return new Student();
    }

    @Bean
    @RequestScope
    public Student requestStu(){
        return new Student();
    }

    @Bean
    @SessionScope
    public Student sessionnStu(){
        return new Student();
    }

    @Bean
    @ApplicationScope
    public Student applicationStu(){
        return new Student();
    }

    @Bean
    @Scope("webSocket")
    public Student webSocket(){
        return new Student();
    }
}
